package com.stars.system.reim.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.stars.system.reim.domain.ReimDailyStat;
import com.stars.system.reim.domain.ReimDailyStatVO;
import com.stars.system.reim.service.IReimDailyStatService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 报销统计记录Controller
 * 
 * @author shuaibizhe
 * @date 2023-01-19
 */
@RestController
@RequestMapping("/reim/daily/stat")
public class ReimDailyStatController extends BaseController
{
    @Autowired
    private IReimDailyStatService reimDailyStatService;

    /**
     * 查询报销统计记录列表
     */
    @PreAuthorize("@ss.hasPermi('daily:stat:list')")
    @GetMapping("/list")
    public TableDataInfo list(ReimDailyStat reimStat)
    {
        startPage();
        List<ReimDailyStatVO> list = reimDailyStatService.selectReimDailyStatList(reimStat);
        return getDataTable(list);
    }

//    /**
//     * 导出报销统计记录列表
//     */
//    @PreAuthorize("@ss.hasPermi('reim:stat:export')")
//    @Log(title = "报销统计记录", businessType = BusinessType.EXPORT)
//    @PostMapping("/export")
//    public void export(HttpServletResponse response, ReimStat reimStat)
//    {
//        List<ReimStat> list = reimDailyStatService.selectReimDailyStatList(reimStat);
//        ExcelUtil<ReimStat> util = new ExcelUtil<ReimStat>(ReimStat.class);
//        util.exportExcel(response, list, "报销统计记录数据");
//    }

    /**
     * 获取报销统计记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('daily:stat:query')")
    @GetMapping(value = "/{statId}")
    public AjaxResult getInfo(@PathVariable("statId") String statId)
    {
        return AjaxResult.success(reimDailyStatService.selectReimDailyStatByStatId(statId));
    }

    /**
     * 新增报销统计记录
     */
    @PreAuthorize("@ss.hasPermi('daily:stat:add')")
    @Log(title = "报销统计记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ReimDailyStat reimStat)
    {
        return toAjax(reimDailyStatService.insertReimDailyStat(reimStat));
    }

    /**
     * 修改报销统计记录
     */
    @PreAuthorize("@ss.hasPermi('daily:stat:edit')")
    @Log(title = "报销统计记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ReimDailyStat reimStat)
    {
        return toAjax(reimDailyStatService.updateReimDailyStat(reimStat));
    }

    /**
     * 删除报销统计记录
     */
    @PreAuthorize("@ss.hasPermi('daily:stat:remove')")
    @Log(title = "报销统计记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{statIds}")
    public AjaxResult remove(@PathVariable String[] statIds)
    {
        return toAjax(reimDailyStatService.deleteReimDailyStatByStatIds(statIds));
    }
}
